import uiautomation
import pyautogui
class chufangtuiyao():
        his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
        his.SetFocus()

        chaxun = his.ButtonControl(AutomationId='btnQuery', ClassName='Button',Name='查询')#查询
        tuiyao = his.ButtonControl(AutomationId='btnTuiYao', ClassName='Button',Name='退药') #退药
        xingmingshurukang = his.EditControl(AutomationId='hzxm_txt',ClassName='TextBox')#姓名输入框

        shujuwangge = his.DataGridControl(AutomationId='tylist_dg',ClassName='DataGrid')
        shuju1 = shujuwangge.DataItemControl(ClassName='DataGridRow',Name='Ksy.ChssClient.Access.Model.TYLB',foundIndex=1)
        shuju2 = shujuwangge.DataItemControl(ClassName='DataGridRow',Name='Ksy.ChssClient.Access.Model.TYLB',foundIndex=2)
        shuju3 = shujuwangge.DataItemControl(ClassName='DataGridRow',Name='Ksy.ChssClient.Access.Model.TYLB',foundIndex=3)

        quanxuanbiaotou = his.HeaderItemControl(ClassName='DataGridColumnHeader',Name='System.Windows.Controls.CheckBox 内容: IsChecked:True')
        tishi1 = his.WindowControl(ClassName='Window',Name='温馨提示')
        queding = tishi1.ButtonControl(AutomationId='OkBtn',ClassName='Button',Name='确定')
        quxiao = tishi1.ButtonControl(AutomationId='CancelBtn',ClassName='Button',Name='取消')
        tishi2 = his.WindowControl(ClassName='Window',Name='提示')
        dayingtuiyaodan_yes = tishi2.ButtonControl(AutomationId='YesBtn',ClassName='Button',Name='是')
        dayingtuiyaodan_no = tishi2.ButtonControl(AutomationId='NoBtn',ClassName='Button',Name='否')
        yulanguanbi = his.WindowControl(ClassName='Window',Name='预览').ButtonControl(ClassName='Button',Name='关闭')


        #输入姓名
        def input_name(self,name):
                self.xingmingshurukang.Click()
                pyautogui.hotkey('ctrl', 'a')
                pyautogui.press('back')
                self.xingmingshurukang.SendKeys(name)

        #点击查询按钮
        def click_cx_btn(self):
                self.chaxun.Click()

        #点击发药
        def click_ty_btn(self):
                self.tuiyao.Click()

        #选择数据1
        def choose_sj1(self):
                self.shuju1.DoubleClick()

        #选择数据2
        def choose_sj2(self):
                self.shuju2.DoubleClick()

        #选择数据3
        def choose_sj3(self):
                self.shuju3.DoubleClick()

        #点击全选标头
        def click_qxbt_btn(self):
                self.quanxuanbiaotou.DoubleClick()

        #点击提示确定按钮
        def click_qd_btn(self):
                self.queding.Click()
        #点击提示取消按钮
        def click_qx_btn(self):
                self.quxiao.Click()
        #点击提示打印退药单是按钮
        def click_yes_btn(self):
                self.dayingtuiyaodan_yes.Click()
        #点击提示打印退药单否按钮
        def click_no_btn(self):
                self.dayingtuiyaodan_no.Click()
        #点击预览关闭按钮
        def click_ylgb_btn(self):
                self.yulanguanbi.Click()